<template>
	<div class="content">
		<div class="ad_content">
			<div class="ad_tittle_content" @click="topage(pageList[0].id)" bubble="true">
				<div class="tittle"><text>{{pageList[0].name}}</text></div>
				<div class="more_text"><text class="all_text">更多</text>
					<text class="title2">&#xe61f;</text>
				</div>
			</div>
			<div class="subtitle_context" @click="topage(pageList[0].id)"><text class="subtitle_text">{{pageList[0].description}}</text></div>
			<div class="across_ad_content_hidden">
				<scroller class="scroller" scroll-direction="horizontal" show-scrollbar="false">
					<div class="ad_item1" v-for="item in navigations" :key="item.id" @click="toLink(item)">
						<image :src="item.logo" style="height: 196px;width: 392px;"></image>
					</div>
				</scroller>
			</div>
		</div>
	</div>

</template>
<script>
	const eeui = app.requireModule('eeui');
	import {
		list as wxPageList
	} from '../../../../api/wxPage'
	import {
		list as navigationList
	} from '../../../../api/navigation'
	export default {
		name: 'acrossService',
		data() {
			return {
				navigations: [],
				pageList: [{id:'',name:'',description:''}],
				tagIds: [],
			}
		},
		created() { // 在实例创建完成后被立即调用
			this.loadPage()
			this.initIconFont()
			this.loadnavigation()
		},
		props: ['content'],
		methods: {
			topage(e) {
				eeui.openPage({
					url: 'root://pages/index/wxPage/wxPage.js',
					params: e,
					statusBarType: 'immersion',
					statusBarStyle:false
				})
			},
			toLink(e) {
				if (e.type == 1) {
					eeui.openPage({
						url: 'root://pages/goods/category/category.js',
						statusBarType: 'immersion',
						statusBarStyle:false,
						params: e.typeId
					})
				}
				if (e.type == 2) {
					eeui.openPage({
						url: 'root://pages/index/wxPage/wxPage.js',
						statusBarType: 'immersion',
						statusBarStyle:false,
						params: e.typeId
					})
				}
				if (e.type == 3) {
					eeui.openPage({
						url: 'root://pages/goods/product/details.js',
						statusBarType: 'immersion',
						statusBarStyle:false,
						params: e.typeId
					})
				}
			},
			loadPage() {
				if (this.content.tagids != null) {
					this.tagIds = this.content.tagids.split(',');
					for (var i = 0; i < this.tagIds.length; i++) {
						this.tagIds[i] = parseInt(this.tagIds[i])
					}
				}
				wxPageList({
					mchId: this.getGlobalData().mchId,
					tagIds: this.tagIds
				}).then(res => {
					this.pageList = res.data.data
				})
			},
			loadnavigation() {
				if (this.content.tagids != null) {
					this.tagIds = this.content.tagids.split(',');
					for (var i = 0; i < this.tagIds.length; i++) {
						this.tagIds[i] = parseInt(this.tagIds[i])
					}
				}
				if (this.tagIds.length > 0) {
					navigationList({
						mchId: this.getGlobalData().mchId,
						tagIds: this.tagIds
					}).then(res => {
						res.data.data.forEach(item => {
							item.logo = this.thumbnail(item.logo, 430, 196)
						})
						this.navigations = res.data.data
					})
				} else {
					navigationList({
						mchId: this.getGlobalData().mchId,
					}).then(res => {
						res.data.data.forEach(item => {
							item.logo = this.thumbnail(item.logo, 430, 196)
						})
						this.navigations = res.data.data
					})
				}
			},
		},
		components: {},
	}
</script>

<style scoped>
	.icon {
		width: 50px;
		height: 50px;
		color: rgba(42, 42, 54,1);
		opacity: 0.3;

	}
	.title2 {
		color: gray;
		font-size: 32px;
		font-family: iconfont2;
		margin-top: 5px;
		color: #cccccc;
	}
	.content {
		padding-left: 20px;
		padding-right: 20px;
		margin-top: 20px;
		border-radius: 16px;
	}

	.scroller {
		height: 200px;
		margin-top: 20px;
		display: flex;
		flex-direction: row;
		margin-bottom: 10px;
	}

	.ad_content {
		display: flex;
		background-color: white;
		border-radius: 16px;
		flex-direction: column;
		padding-left: 20px;
		padding-top: 20px;
		padding-right: 20px;
		overflow: hidden;
	}

	.more_text {
		display: flex;
		flex-direction: row;
	}

	.ad_tittle_content {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}

	.all_text {
		margin-top: 9px;
		height: 30px;
		font-size: 28px;
		font-weight: 400;
		color: rgba(26, 26, 30, 0.3);
	}



	.tittle {
		height: 30px;
		font-size: 36px;
		font-weight: 500;
		color: rgba(26, 26, 30, 1);
	}

	.subtitle_text {

		font-size: 24px;
		font-weight: 400;
		color: rgba(26, 26, 30, 0.5);
	}

	.across_ad_content {
		overflow-x: auto;
		display: flex;
		flex-direction: row;
		width: 730px;
		height: 223px;
		margin-top: 20px;
		margin-bottom: 10px;
	}


	.ad_item1 {
		flex-shrink: 0;
		margin-right: 10px;
		height: 196px;
		width: 392px;
		background: linear-gradient(0deg, rgba(250, 239, 231, 1), rgba(250, 247, 245, 1));
		border-radius: 16px;
	}

	.image_content {
		width: 427px;
	}

	.line_content {
		margin-left: 12px;
	}

	.ad_item2 {
		width: 326px;
		height: 164px;
		background: linear-gradient(0deg, rgba(237, 243, 247, 1), rgba(250, 253, 255, 1));
	}

	.ad_item3 {
		margin-top: 12px;
		width: 326px;
		height: 164px;
		background: linear-gradient(0deg, rgba(251, 245, 232, 1), rgba(250, 248, 245, 1));
	}
</style>
